<template>
    <div class="register--box">
      <input v-model="regInfo.phoneNumber" type="text" placeholder="请输入手机号" class="phoneNumber"><br/>
      <input v-model="regInfo.validCode" type="text" placeholder="请输入手机验证码" class="phoneNumber"><span @click="validCode" class="balidCode">获取验证码</span>
      <input v-model="regInfo.password" type="text" placeholder="请输入6-12位密码" class="phoneNumber"><br/>
      <div class="label">
        <input v-model="regInfo.isAgree" id="provision" type="checkbox">
        <label for="provision" class="aa"><span class="bb">我已阅读并同意<span class="span">《商城销售条款》</span></span></label>
        <!--class="clause"-->
      </div>
      <div @click="register" class="register">注册</div>

    </div>
</template>

<script>
  export default {
    name: "register",
    data() {
      return {
        regInfo: {
          phoneNumber: '',
          validCode: '',
          password: '',
          isAgree: false,
        }
      };
    },
    methods: {
      register() {
        this.$apis.register(this.regInfo)
          .then(data => {
            console.log(data)
          })
          .catch(error =>{
            console.log(error)
          })
      },
      validCode() {
        this.$apis.validCode()
          .then( (data) => console.log(data) )
          .catch( (error) => console.log(error) )
      }
    },
  }
</script>

<style scoped>
  .phoneNumber{
    width: 80%;
    height: 1.16rem;
    border: none;
    border-bottom: 1px solid rgba(0, 0, 0, .1);
    position: relative;
    left: 10%;
    outline: none;
    font-size: .3rem;
  }
  .register--box{
    position: relative;
    top: 1.4rem;
  }
  .label{
    width: 80%;
    height: 1.16rem;
    text-align: left;
    position: relative;
    left: 10%;
    right: 10%;
    /*line-height: 1rem;*/
    top: 1vh;
    vertical-align: middle;
  }
  .label>label,input{
    vertical-align:top;
    font-size: .3rem;
  }
  .register{
    position: relative;
    top: 1rem;
    width: 70%;
    height: 1rem;
    background-color: #3868E4;
    text-align: center;
    line-height: 1rem;
    color: white;
    left: 15%;
    border-radius: 1rem;
    font-size: .45rem;
  }
  .span{
    color: #166ee4;
  }
  #provision{
    display: none;
  }
  .aa{
    display: inline-block;
    width: 20px;
    height: 20px;
    border: silver 1px solid;
    border-radius: 50%;
  }
  .bb{
    display: inline-block;
    width: 70vw;
    vertical-align: middle;
    position: relative;
    left: 32px;
    top: -.6vh;
  }
  input:checked + .aa {
    background: #3c9dfc;
    background-image: url("../assets/checked.png");
    background-size: 20px 20px;
    background-position: center;
  }
  .balidCode{
    color: deepskyblue;
    position: absolute;
    line-height: 1.2rem;
    right: 1rem;
  }
</style>
